package com.leyou.search.web;

import com.leyou.search.dto.SearchRequest;
import com.leyou.search.entity.Goods;

import com.leyou.search.service.SearchService;
import com.leyou.starter.elastic.entity.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/goods")
public class SearchController {
    @Autowired
    private SearchService searchService;

    @GetMapping("/suggestion")
    public Mono<List<String>> suggest(@RequestParam("key")String key){
        return this.searchService.suggest(key);
    }

    //基本搜索条件查询

    @PostMapping("/list")
    public Mono<PageInfo<Goods>> querylist(@RequestBody SearchRequest searchRequest){
        return this.searchService.querylist(searchRequest);
    }

    //过滤条件查询
    @PostMapping("/filter")
    public Mono<Map<String,List<?>>> filterlist(@RequestBody SearchRequest searchRequest){
        return this.searchService.filterlist(searchRequest);
    }
}
